import request from "./http";
let errCount = 0;

async function requestHandler(url, method, header = {}, data = {}) {
	let result;
	try {
		// console.log(data);
		result = await request({
			url,
			method,
			header,
			data
		});
	} catch (err) {
		errCount++;
		if (errCount <= 3) {
			result = await requestHandler(url, method, header, data);
		}
	}
	return result;
}

export default requestHandler;